package com.gl.order.security.handle;

import com.gl.order.commom.util.ResponseUtils;
import com.gl.order.commom.ResultBean;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: liangSY
 * @Date: 2021/6/8 13:06
 * @ClassName: UserAccessDeniedHandler
 * 无权限处理类
 */
public class UserAccessDeniedHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        ResponseUtils.responseJson(response,ResultBean.failed(ResultBean.NO_PERMISSION,accessDeniedException.getMessage()));
    }

}
